﻿<navigation:Page x:Class="Thor.Silverlight.Views.Settings" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
            xmlns:dataFormToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
            xmlns:domainServices="clr-namespace:Thor.WebRole.Services"
            xmlns:activity="clr-namespace:System.Windows.Controls;assembly=ActivityControl"
            xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Ria"
            xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
            xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"
            xmlns:local="clr-namespace:Thor.Silverlight"
           Title="settings">
    <navigation:Page.Resources>
        <local:ProviderAssemblyValueConverter x:Key="providerAssemblyValueConverter" />
    </navigation:Page.Resources>
    <Grid x:Name="LayoutRoot">
        
        <riaControls:DomainDataSource x:Name="domainDataSource1"
                                      AutoLoad="True"
                                      QueryName="GetSettings" >

            <riaControls:DomainDataSource.DomainContext>
                <domainServices:SettingsManagerDomainContext />
            </riaControls:DomainDataSource.DomainContext>

        </riaControls:DomainDataSource>

        <StackPanel Orientation="Vertical">
            <activity:Activity IsActive="{Binding IsBusy, ElementName=domainDataSource1}">
                <dataFormToolkit:DataForm x:Name="dataForm1" 
                                  AutoGenerateFields="False"
                                  CommandButtonsVisibility="Commit,Cancel"
                                  ItemsSource="{Binding Data, ElementName=domainDataSource1}" EditEnded="dataForm1_EditEnded" Margin="0"
                                          ContentLoaded="dataForm1_ContentLoaded">

                    <dataFormToolkit:DataForm.EditTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Vertical">
                                <StackPanel Orientation="Horizontal">
                                    <StackPanel Orientation="Vertical" Margin="3,3,3,3">
                                        <TextBlock Text="{Binding ApplicationStrings.CalendarLabel, Source={StaticResource ResourceWrapper}}" Style="{StaticResource groupHeaderStyle}" />
                                        <Border Style="{StaticResource groupBorderStyle}">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition />
                                                    <RowDefinition />
                                                    <RowDefinition />
                                                    <RowDefinition />
                                                </Grid.RowDefinitions>

                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition />
                                                    <ColumnDefinition />
                                                </Grid.ColumnDefinitions>
                                                
                                                <HyperlinkButton Content="{Binding ApplicationStrings.ProviderLabel, Source={StaticResource ResourceWrapper}}" 
                                                           Grid.Row="0" Grid.Column="0" Style="{StaticResource requiredHyperlinkButtonStyle}" 
                                                                 x:Name="ProviderHyperlinkButton" Click="ProviderHyperlinkButton_Click"></HyperlinkButton>
                                                
                                                <TextBlock Text="{Binding ApplicationStrings.ProviderAssemblyLabel, Source={StaticResource ResourceWrapper}}" 
                                                           Grid.Row="1" Grid.Column="0" Style="{StaticResource labelStyle}" />
                                                <dataFormToolkit:DataField Grid.Row="1" Grid.Column="1" LabelVisibility="Collapsed">
                                                    <ComboBox x:Name="ProviderAssembliesComboBox" SelectionChanged="ProviderAssembliesComboBox_SelectionChanged" 
                                                              SelectedItem="{Binding AssemblyName, Mode=TwoWay}" Width="250" >
                                                    </ComboBox>
                                                </dataFormToolkit:DataField>
                                                
                                                <TextBlock Text="{Binding ApplicationStrings.ProviderTypeLabel, Source={StaticResource ResourceWrapper}}" 
                                                           Grid.Row="2" Grid.Column="0" Style="{StaticResource labelStyle}" />
                                                <dataFormToolkit:DataField Grid.Row="2" Grid.Column="1" LabelVisibility="Collapsed">
                                                    <ComboBox x:Name="ProviderTypesComboBox" 
                                                              SelectedItem="{Binding AssemblyType, Mode=TwoWay}"  Width="250">
                                                    </ComboBox>
                                                </dataFormToolkit:DataField>

                                                <TextBlock Text="{Binding ApplicationStrings.ProviderUriLabel, Source={StaticResource ResourceWrapper}}" 
                                                           Grid.Row="3" Grid.Column="0" Style="{StaticResource requiredLabelStyle}" />
                                                <dataFormToolkit:DataField Grid.Row="3" Grid.Column="1" LabelVisibility="Collapsed">
                                                    <TextBox Text="{Binding CalendarProviderUri, Mode=TwoWay}"  Width="250" Style="{StaticResource textFieldStyle}" />
                                                </dataFormToolkit:DataField>
                                                
                                            </Grid>
                                        </Border>
                                        <TextBlock Text="{Binding ApplicationStrings.AuthenticationLabel, Source={StaticResource ResourceWrapper}}" Style="{StaticResource groupHeaderStyle}" />
                                        <Border Style="{StaticResource groupBorderStyle}">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition />
                                                    <RowDefinition />
                                                    <RowDefinition />
                                                </Grid.RowDefinitions>

                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition />
                                                    <ColumnDefinition />
                                                </Grid.ColumnDefinitions>

                                                <TextBlock Text="{Binding ApplicationStrings.UserNameLabel, Source={StaticResource ResourceWrapper}}" 
                                                           Grid.Row="0" Grid.Column="0" Style="{StaticResource requiredLabelStyle}" />
                                                <dataFormToolkit:DataField Grid.Row="0" Grid.Column="1" LabelVisibility="Collapsed">
                                                    <TextBox Text="{Binding UserName, Mode=TwoWay}"  Width="250"  Style="{StaticResource textFieldStyle}"/>
                                                </dataFormToolkit:DataField>
                                                
                                                <TextBlock Text="{Binding ApplicationStrings.PasswordLabel, Source={StaticResource ResourceWrapper}}" 
                                                           Grid.Row="1" Grid.Column="0" Style="{StaticResource requiredLabelStyle}" />
                                                <dataFormToolkit:DataField Grid.Row="1" Grid.Column="1" LabelVisibility="Collapsed">
                                                    <PasswordBox Password="{Binding Password, Mode=TwoWay}"  Width="250" Style="{StaticResource passwordFieldStyle}" />
                                                </dataFormToolkit:DataField>
                                                
                                            </Grid>

                                        </Border>
                                        <TextBlock Text="{Binding ApplicationStrings.ServerLabel, Source={StaticResource ResourceWrapper}}" Style="{StaticResource groupHeaderStyle}" />
                                            <Border Style="{StaticResource groupBorderStyle}">
												<Grid>
													<Grid.RowDefinitions>
														<RowDefinition />
													</Grid.RowDefinitions>
												
													<Grid.ColumnDefinitions>
														<ColumnDefinition />
														<ColumnDefinition />
													</Grid.ColumnDefinitions>
												
													<TextBlock Text="{Binding ApplicationStrings.ServerTimeZoneLabel, Source={StaticResource ResourceWrapper}}" 
                                                           Grid.Row="0" Grid.Column="0" Style="{StaticResource labelStyle}" />
												
													<dataFormToolkit:DataField Grid.Row="0" Grid.Column="1" LabelVisibility="Collapsed">
                                                    	<ComboBox x:Name="ServerTimeZonesComboBox" SelectedItem="{Binding ServerTimeZone, Mode=TwoWay}" Width="250" >
                                                    	</ComboBox>
                                                	</dataFormToolkit:DataField>
												
												</Grid>
                                            </Border>
                                    </StackPanel>
                                    <StackPanel Orientation="Vertical" Margin="3,3,3,3">
                                        <TextBlock Text="{Binding ApplicationStrings.BookingLabel, Source={StaticResource ResourceWrapper}}" Style="{StaticResource groupHeaderStyle}" />
                                        <Border Style="{StaticResource groupBorderStyle}">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition />
                                                    <RowDefinition />
                                                </Grid.RowDefinitions>
                                                
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition />
                                                    <ColumnDefinition />
                                                </Grid.ColumnDefinitions>

                                                <TextBlock Text="{Binding ApplicationStrings.UseBookingAgentLabel, Source={StaticResource ResourceWrapper}}" 
                                                           Grid.Row="0" Grid.Column="0" Style="{StaticResource labelStyle}" />
                                                <dataFormToolkit:DataField Grid.Row="0" Grid.Column="1" LabelVisibility="Collapsed">
                                                    <CheckBox IsChecked="{Binding UseBookingAgent, Mode=TwoWay}" Style="{StaticResource checkBoxFieldStyle}" />
                                                </dataFormToolkit:DataField>
                                                
                                                <TextBlock Text="{Binding ApplicationStrings.BookingAgentEmailLabel, Source={StaticResource ResourceWrapper}}" 
                                                           Grid.Row="1" Grid.Column="0"  Style="{StaticResource labelStyle}"/>
                                                <dataFormToolkit:DataField Grid.Row="1" Grid.Column="1" LabelVisibility="Collapsed">
                                                    <TextBox Text="{Binding BookingAgentEmail, Mode=TwoWay}"  Width="250" Style="{StaticResource textFieldStyle}" />
                                                </dataFormToolkit:DataField>
                                            </Grid>
                                        </Border>
                                        <TextBlock Text="{Binding ApplicationStrings.SecurityLabel, Source={StaticResource ResourceWrapper}}" Style="{StaticResource groupHeaderStyle}" />
                                        <Border Style="{StaticResource groupBorderStyle}">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition />
                                                    <RowDefinition />
                                                    <RowDefinition />
                                                </Grid.RowDefinitions>
                                                
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="115" />
                                                    <ColumnDefinition />
                                                </Grid.ColumnDefinitions>

                                                <TextBlock Text="{Binding ApplicationStrings.RetryCountLabel, Source={StaticResource ResourceWrapper}}" 
                                                           Grid.Row="0" Grid.Column="0" Style="{StaticResource requiredLabelStyle}"/>
                                                <dataFormToolkit:DataField Grid.Row="0" Grid.Column="1" LabelVisibility="Collapsed">
                                                    <TextBox Text="{Binding RetryCount, Mode=TwoWay}" Width="75" Style="{StaticResource textFieldStyle}" />
                                                </dataFormToolkit:DataField>
                                                
                                                <TextBlock Text="{Binding ApplicationStrings.RetryIntervalLabel, Source={StaticResource ResourceWrapper}}" 
                                                           Grid.Row="1" Grid.Column="0" Style="{StaticResource requiredLabelStyle}"/>
                                                <dataFormToolkit:DataField Grid.Row="1" Grid.Column="1" LabelVisibility="Collapsed">
                                                    <TextBox Text="{Binding RetryInterval, Mode=TwoWay}"  Width="75" Style="{StaticResource textFieldStyle}" />
                                                </dataFormToolkit:DataField>
                                                
                                                <TextBlock Text="{Binding ApplicationStrings.LockoutDurationLabel, Source={StaticResource ResourceWrapper}}" 
                                                           Grid.Row="2" Grid.Column="0" Style="{StaticResource requiredLabelStyle}"/>
                                                <dataFormToolkit:DataField Grid.Row="2" Grid.Column="1" LabelVisibility="Collapsed">
                                                    <TextBox Text="{Binding LockoutDuration, Mode=TwoWay}"  Width="75" Style="{StaticResource textFieldStyle}" />
                                                </dataFormToolkit:DataField>
                                            </Grid>
                                        </Border>
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </dataFormToolkit:DataForm.EditTemplate>

                </dataFormToolkit:DataForm>
            </activity:Activity>
        </StackPanel>
    </Grid>
</navigation:Page>
